library Monofilaments initializer init requires Beams
    
    globals
        private constant string MonofilamentMuzzleFlash = "Abilities\\Spells\\NightElf\\SpiritOfVengeance\\SpiritOfVengeanceBirthMissile.mdl"
        private constant string MonofilamentImpact = "Abilities\\Spells\\NightElf\\SpiritOfVengeance\\SpiritOfVengeanceBirthMissile.mdl"
    endglobals

    private function IsSkillMono takes nothing returns boolean
        return GetSpellAbilityId() == 'A00R'
    endfunction
    
    private function MONO takes nothing returns boolean
        local real x = GetSpellTargetX()
        local real y = GetSpellTargetY()
        local real z
        local unit u = GetTriggerUnit()
        
        local real sx = GetUnitX(u)
        local real sy = GetUnitY(u)
        local real sz = GetUnitZ(u) + 37.
            
        local real rad = AngleBetweenPointsRad(sx,sy,x,y)
        local real cos = Cos(rad)
        local real sin = Sin(rad)
            
        local real range = 1000.0

        local integer level = GetUnitAbilityLevel(u, 'A00R')
            
        set sx = GetUnitX(u) + 32.0 * cos
        set sy = GetUnitY(u) + 32.0 * sin
            
        if(level == 1) then
            set range = 900
        elseif(level == 2) then
            set range = 1000
        elseif(level == 3) then
            set range = 1100
        elseif(level == 4) then
            set range = 1200
        elseif(level >= 5) then
            set range = 1300
        endif

        set x = sx + range * cos
        set y = sy + range * sin
        set z = GetZ(x,y) + 10.0
            
        call DestroyEffect(AddSpecialEffectTarget(MonofilamentMuzzleFlash,u,"weapon"))
        
        call BlueLaser(sx,sy,sz, x,y,z-10.0)
        call BlueLaser(sx,sy,sz, x,y+30.0,z+5.0)
        call BlueLaser(sx,sy,sz, x-15.0,y+20.0,z-10.0)
        call BlueLaser(sx,sy,sz, x+20.0,y-15.0,z+5.0)
        
        call TriggerSleepAction(0.1)
        call DestroyEffect(AddSpecialEffect(MonofilamentImpact,x,y+30.0))
        call DestroyEffect(AddSpecialEffect(MonofilamentImpact,x-15.0,y+20.0))
        call DestroyEffect(AddSpecialEffect(MonofilamentImpact,x+20.0,y-15.0))
        call DestroyEffect(AddSpecialEffect(MonofilamentImpact,x,y))  
        
        set u = null
        return false
    endfunction
    
    private function init takes nothing returns nothing
        local trigger t =  CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, Condition (function IsSkillMono))
        call TriggerAddAction(t, function MONO)
    endfunction
    
    
endlibrary